from django.contrib import admin

# Register your models here.

from .models import Question, Choice


# admin.site.register(Choice)
class ChoiceInline(admin.TabularInline):
    model = Choice
    extra = 3


class QuestionAdmin(admin.ModelAdmin):
    fieldsets = [
        (None, {"fields": ["question_text"]}),
        ("Date information", {"fields": ["pub_date"]}),
    ]
    inlines = [ChoiceInline]

    # 在后台管理中添加新列：DATE PUBLISHED
    list_display = ["question_text", "pub_date"]

    # 在后台管理中添加新列：WAS PUBLISHED RECENTLY
    list_display = ["question_text", "pub_date", "was_published_recently"]

    # 在后台管理中添加过滤器，以pub_date进行过滤。
    list_filter = ["pub_date"]

    # 在后台管理中添加一个搜索框
    search_fields = ['question_text']


admin.site.register(Question, QuestionAdmin)


